﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using NeuralNetworks;

namespace ExponentRecognition
{
    class Program
    {
        static int ARRAY_RESOLUTION = 10;
        static double COUNTING_COEF = 100;
        static int RANDOM_DOTS_AMOUNT = 500;

        static void Main(string[] args)
        {
            Brain brain = new Brain(3, (int)Math.Pow(ARRAY_RESOLUTION, 2), 100, 2);
            PlotConverter converter = new PlotConverter(ARRAY_RESOLUTION, RANDOM_DOTS_AMOUNT);

            int counter = 0;
            double errorA = 100, errorC = 100;
            double[] result = new double[2];
            double[] input = converter.ConvertExponent(2, 3, 0, 1, 0, 1);
            while ((errorA + errorC) / 2 > 1) // in percents
            {
                result = brain.Count((double[])input.Clone());
                Console.WriteLine("=====================================================");
                Console.WriteLine("C: {0}, A: {1}\n", result[0] * 10, result[1] * 10);
                brain.Teach((double[])input.Clone(), new double[2] { 0.2, 0.3 }, COUNTING_COEF);

                errorC = (Math.Abs(2 - result[0] * 10) / 2) * 100;
                errorA = (Math.Abs(3 - result[1] * 10) / 3) * 100;
                Console.WriteLine("Error for C: " + errorC + ". Error for A: " + errorA);
                Console.WriteLine("Counter: " + counter.ToString());
                counter++;
            }

            Console.ReadKey();
        }
    }
}
